<template>
	<view>
		<uv-tabbar :value="current" :fixed="true" :placeholder="false" activeColor="#1f1f1f" :safeAreaInsetBottom="true">
			<uv-tabbar-item text="首页" @click="select">
				<template v-slot:active-icon>
					<image style="height:40rpx;width: 40rpx;" class="icon" src="@/static/images/home_a.png"></image>
				</template>
				<template v-slot:inactive-icon>
					<image style="height:40rpx;width: 40rpx;" class="icon" src="@/static/images/home.png"></image>
				</template>
			</uv-tabbar-item>
			<uv-tabbar-item text="找伴" @click="select">
				<template v-slot:active-icon>
					<image style="height:40rpx;width: 40rpx;" class="icon" src="@/static/images/friend_a.png"></image>
				</template>
				<template v-slot:inactive-icon>
					<image style="height:40rpx;width: 40rpx;" class="icon" src="@/static/images/friend.png"></image>
				</template>
			</uv-tabbar-item>
			<uv-tabbar-item @click="select">
				<template v-slot:active-icon>
					<image style="height:90rpx;width: 90rpx;" class="icon" src="@/static/images/sub.png" mode="aspectFill"></image>
					<uv-badge absolute :offset="[4,-9]" value="趣组局" shape="horn" bgColor="#FF0000"></uv-badge>
				</template>
				<template v-slot:inactive-icon>
					<image style="height:90rpx;width: 90rpx;" class="icon" src="@/static/images/sub.png" mode="aspectFill"></image>
					<uv-badge absolute :offset="[4,-9]" value="趣组局" shape="horn" bgColor="#FF0000"></uv-badge>
				</template>
			</uv-tabbar-item>
			<uv-tabbar-item text="消息" @click="select">
				<template v-slot:active-icon>
					<image style="height:40rpx;width: 40rpx;" class="icon" src="@/static/images/message_a.png"></image>
				</template>
				<template v-slot:inactive-icon>
					<image style="height:40rpx;width: 40rpx;" class="icon" src="@/static/images/message.png"></image>
				</template>
			</uv-tabbar-item>
			<uv-tabbar-item text="我的" @click="select">
				<template v-slot:active-icon>
					<image style="height:40rpx;width: 40rpx;" class="icon" src="@/static/images/my_a.png"></image>
				</template>
				<template v-slot:inactive-icon>
					<image style="height:40rpx;width: 40rpx;" class="icon" src="@/static/images/my.png"></image>
				</template>
			</uv-tabbar-item>
		</uv-tabbar>
	</view>
</template>

<script setup>
	import { onLoad, onShow } from '@dcloudio/uni-app'
	import { useUserStore } from '@/store/index.js'
	import { ref, reactive, watch } from 'vue';
	const props = defineProps({
		current: Number,
		getTaskList: Function,
		reflah: Boolean
	})
	const useUser = useUserStore()
	const tabIndex = ref(0)
	const list = reactive(
		[{
				path: '/pages/index/index'
			},
			{
				path: '/pages/friends/index'
			},
			{
				path: '/pages/publish/index'
			},
			{
				path: '/pages/message/index',
				// path: '/TUIKit/components/TUIConversation/index'
			},
			{
				path: '/pages/my/index'
			},
		]
	)
	// 监听tabbar
	watch(() => useUser.tabIndex, (newVal, oldVal) => {
		// console.log(newVal,oldVal,'===========')
		if (newVal == 1 && props.getTaskList) {
			props.getTaskList()
		}
	})
	const select = (e) => {
		uni.switchTab({
			url: list[e].path,
			success: () => {
				setTabIndex(e)
			}
		})
	}
	// const change = (e) => {
	// 	uni.switchTab({
	// 		url: list[e].path,
	// 		success: () => {
	// 			setTabIndex(e)
	// 		}
	// 	})
	// }
	const setTabIndex = (tabIndex) => {

		// if(props.reflah&&tabIndex==1){
		// 	console.log(tabIndex)
		// 	props.getTaskList()
		// }
		useUser.tabIndex = tabIndex
	}
</script>

<style>

</style>